package com.bw.unit6.util

import android.content.Context
import android.view.RoundedCorner
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.CircleCrop
import com.bumptech.glide.load.resource.bitmap.RoundedCorners

/**
 *
 * @ClassName: GlideUtil
 * @Description: 图片单例工具类
 * @Author: zhangyanchao
 * @CreateDate: 2024/9/23 5:19 PM
 * @Version: 1.0
 */
object GlideUtil {

    /**
     * 加载图片
     * @param context Context
     * @param url String
     * @param imageView ImageView
     */
    fun loadImg(context: Context,url:String,imageView: ImageView){
        Glide.with(context).load(url).into(imageView)
    }

    /**
     * 加载圆角图片
     * @param context Context
     * @param url String
     * @param imageView ImageView
     */
    fun loadCornerImg(context: Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .transform(RoundedCorners(24))
            .into(imageView)
    }

    /**
     * 加载圆形图片
     * @param context Context
     * @param url String
     * @param imageView ImageView
     */
    fun loadCircleImg(context: Context,url:String,imageView: ImageView){
        Glide.with(context)
            .load(url)
            .transform(CircleCrop())
            .into(imageView)
    }
}